<?php

/**
 * This is the model class for table "hs_order_pay".
 *
 * The followings are the available columns in table 'hs_order_pay':
 * @property integer $id
 * @property string $order_no
 * @property string $order_amount
 * @property string $qid
 * @property string $pay_time
 * @property string $trace_no
 * @property string $trace_time
 * @property string $settle_amount
 * @property integer $pay_type
 */
class OrderPay extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return OrderPay the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'hs_order_pay';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('order_no, order_amount, qid, pay_time, trace_no, trace_time, settle_amount, pay_type', 'required'),
			array('pay_type', 'numerical', 'integerOnly'=>true),
			array('order_no', 'length', 'max'=>32),
			array('order_amount', 'length', 'max'=>12),
			array('qid, trace_no', 'length', 'max'=>128),
			array('pay_time, trace_time, settle_amount', 'length', 'max'=>64),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, order_no, order_amount, qid, pay_time, trace_no, trace_time, settle_amount, pay_type', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'order_no' => 'Order No',
			'order_amount' => 'Order Amount',
			'qid' => 'Qid',
			'pay_time' => 'Pay Time',
			'trace_no' => 'Trace No',
			'trace_time' => 'Trace Time',
			'settle_amount' => 'Settle Amount',
			'pay_type' => 'Pay Type',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('order_no',$this->order_no,true);
		$criteria->compare('order_amount',$this->order_amount,true);
		$criteria->compare('qid',$this->qid,true);
		$criteria->compare('pay_time',$this->pay_time,true);
		$criteria->compare('trace_no',$this->trace_no,true);
		$criteria->compare('trace_time',$this->trace_time,true);
		$criteria->compare('settle_amount',$this->settle_amount,true);
		$criteria->compare('pay_type',$this->pay_type);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}